package org.micode.common.syslog;

import org.micode.common.config.ApplicationConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@DependsOn("springContextHolder")
@Configuration
public class SysLogConfigurer {

    private static final String HANDLER_CLASS_KEY = "spring.syslog.handler";

    @Bean(name = "sysLogSaver")
    public ISysLogSaver<?> getSysLogSaver() {
        String className = ApplicationConfig.readString(HANDLER_CLASS_KEY, null);
        return SysLogSaverFactory.newSysLogSaver(className);
    }

}
